#!/bin/sed -f
#
# This script will convert from an osm.xml file back to osm-template.xml
# You will probably need to tweak this file to reverse your customisations
#
# $ ./convert-template osm.xml > osm-template.xml-new
#
#


# replace the server with the local postgis database
# <Parameter name="host">dev.openstreetmap.org</Parameter>
s|<Parameter name="host">.*</Parameter>|<Parameter name="host">%DBHOST%</Parameter>|


# Since we normally run on localhost; we can delete these lines
#      <Parameter name="port">5433</Parameter>     
s/<Parameter name="port">.*<\/Parameter>/<Parameter name="port">%DBPORT%<\/Parameter>/


#      <Parameter name="user">steve</Parameter>
s/"user">.*</"user">%DBUSER%</

# If I connect to a local socket i don't need any username
# This only works with the newest Mapnik 
#/<Parameter name="user">steve<\/Parameter>/d

#      <Parameter name="dbname">mapnik</Parameter>
s/"dbname">.*</"dbname">%DBNAME%</


#       <Parameter name="file">/Users/artem/world_boundaries/places</Parameter>
s|/Users/artem/world_boundaries/|%WORLD_BOUNDARIES_DIR%/|
s|/home/steve/world_boundaries/|%WORLD_BOUNDARIES_DIR%/|
s|/home/jburgess/osm/data/world_boundaries/|%WORLD_BOUNDARIES_DIR%/|
s|/home/jburgess/world_boundaries/|%WORLD_BOUNDARIES_DIR%/|
s|c:/boundaries/world_boundaries/|%WORLD_BOUNDARIES_DIR%/|

# PointSymbolizer file="/Users/artem/symbols/recycling.png" type="png" width="20" height="20" />
s|/Users/artem/symbols/|%SYMBOLS_DIR%/|
s|/home/steve/symbols/|%SYMBOLS_DIR%/|
s|c:/mapnik/symbols/|%SYMBOLS_DIR%/|
s|/home/jburgess/osm/svn.openstreetmap.org/applications/rendering/mapnik/symbols/|%SYMBOLS_DIR%/|
s|/home/jburgess/svn.openstreetmap.org/applications/rendering/mapnik/symbols/|%SYMBOLS_DIR%/|

# /home/jburges/osm/data/world_boundaries
s|/home/jburges/osm/data/world_boundaries|%WORLD_BOUNDARIES_DIR%|
s|/home/jburgess/new-coast/coastlines|%WORLD_BOUNDARIES_DIR%|

# Add the database password prior to the name
#/<Parameter name="dbname">/ i \      <Parameter name="password">%DBPASS%</Parameter>

#       <Parameter name="host">%DBHOST%</Parameter>\
#      <Parameter name="port">%DBPORT%</Parameter>\
#      <Parameter name="user">%DBUSER%</Parameter>\

/<Parameter name="dbname">/ i \
      <Parameter name="password">%DBPASS%</Parameter>

# Use template for PostGIS table names
s/planet_osm_/%PREFIX%_/g

# Steve8 leaves these in the file
/"password">martyn/d
/"password">xxxxxx/d
